package cn.hwl.springframework.context.support;

import cn.hwl.springframework.beans.factory.support.DefaultListableBeanFactory;
import cn.hwl.springframework.beans.factory.xml.XmlBeanDefinitionReader;

/**
 * @author :  HuangWL
 * @date :    2022/4/28 16:09
 */
public abstract class AbstractXmlApplicationContext extends AbstractRefreshableApplicationContext {


    /**
     * 处理了关于 XML 文件配置信息的操作
     */
    @Override
    protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) {
        XmlBeanDefinitionReader beanDefinitionReader = new XmlBeanDefinitionReader(beanFactory, this);
        String[] configLocations = getConfigLocations();
        if (null != configLocations){
            beanDefinitionReader.loadBeanDefinitions(configLocations);
        }
    }

    /**
     * 为了从入口上下文类，拿到配置信息的地址描述
     */
    protected abstract String[] getConfigLocations();
}
